package com.atguigu.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletContext extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        javax.servlet.ServletContext context = getServletConfig().getServletContext();
        String username = context.getInitParameter("username");
        System.out.println("context-param参数usernaem的值是:"+username);
        System.out.println("context-param参数的值是:"+context.getInitParameter("password"));
        System.out.println("当前工程路径:"+context.getContextPath());
        System.out.println("工程部署的路径是:"+ context.getRealPath("/"));
        System.out.println("工程下css目录的绝对路径是:"+ context.getRealPath("/css"));
        System.out.println("工程下imgs目录1.jpg的绝对路径是:"+context.getRealPath("/imgs/1.jpg"));


    }
}
